﻿using System.Data.Entity;
using LabNet.Server.Domain;

namespace LabNet.Server.Configuration
{
    public class RoleConfiguration
    {
        public static void Map(DbModelBuilder modelBuilder)
        {
            modelBuilder
                .Entity<Role>()
                .ToTable("Role");

            modelBuilder
                .Entity<Role>()
                .HasMany(o => o.Users)
                .WithRequired(o => o.Role)
                .HasForeignKey(o => o.RoleId);

            modelBuilder
                .Entity<Role>()
                .HasMany(o => o.Groups)
                .WithRequired(o => o.Role)
                .HasForeignKey(o => o.RoleId);

        }
    }
}